<?php
namespace app\admin\model;

use think\Model;

class arole extends Model
{
    public static function aroleAdd($data)
    {
        $data['update_time'] = $data['create_time'] = time();
        $id = self::field('rolename,status,create_time,update_time')->insertGetId($data);
        if(!$id) throw new \Exception('添加角色失败');

        return $id;
    }

    public static function aroleUpdate($data)
    {
        $id = $data['roleid'];
        $data['update_time'] = time();
        $result = self::field('roleid,rolename,powerid,status,create_time,update_time')->update($data);
        if(!$result) throw new \Exception('修改角色失败');
        return $id;
    }

    public static function aroleDel($where)
    {
        $result = self::where($where)->delete();
        if(!$result) throw new \Exception('删除角色失败');
    }
}